package cn.iocoder.devlop.module.annual.report.marpripinfo.controller.app;

import cn.iocoder.devlop.framework.common.pojo.CommonResult;
import cn.iocoder.devlop.module.annual.report.marpripinfo.controller.vo.CheckResp;
import cn.iocoder.devlop.module.annual.report.marpripinfo.dal.dataobject.MarpripinfoDO;
import cn.iocoder.devlop.module.annual.report.marpripinfo.service.MarpripinfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

import static cn.iocoder.devlop.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 企业基本信息")
@RestController
@RequestMapping("/annual/report/marpripinfo")
@Validated
public class AppMarpripinfoController {

    @Resource
    private MarpripinfoService marpripinfoService;

    @GetMapping("/check")
    @Operation(summary = "登录前的检查")
    @PermitAll
    @Parameter(name = "regno", description = "企业统一代码或者注册号", required = true)
    public CommonResult<CheckResp> checkMarpripinfo(@RequestParam("regno") String regno) {
        CheckResp checkResp = marpripinfoService.checkMarpripinfo(regno);
        return success(checkResp);
    }

    @GetMapping("/has-children")
    @Operation(summary = "是否有子公司")
    @Parameter(name = "regno", description = "企业统一代码或者注册号", required = true)
    public CommonResult<List<MarpripinfoDO>> hasChildren(@RequestParam("regno") String regno){
        return success(marpripinfoService.getChildren(regno));
    }

}
